<?php


namespace Yj\Apidog\Annotation;

use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\Mapping;

/**
 * Annotation class for @PostApi().
 *
 * @Annotation
 * @Target({"METHOD"})
 *
 */
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)]
class PostApi extends Mapping
{


    public $path;

    public $summary;

    public $description;

    public $deprecated;

    public $methods = ['POST'];

    public function __construct($path, $description = '')
    {
        if (is_array($path)) {
            parent::__construct($path);
            foreach ($path as $key => $val) {
                if (property_exists($this, $key)) {
                    $this->{$key} = $val;
                }
            }
        } else {
            parent::__construct($path, $description);
            $this->path = $path;
            $this->description = $description;
        }

    }

//    public function __construct($value = null)
//    {
//        parent::__construct($value);
//        if (is_array($value)) {
//            foreach ($value as $key => $val) {
//                if (property_exists($this, $key)) {
//                    $this->{$key} = $val;
//                }
//            }
//        }
//    }
}